package com.ruoyi.quality.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.quality.domain.dto.InspectionItemDto;
import com.ruoyi.quality.service.InspectionItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.text.ParseException;

@RestController
@RequestMapping("/inspectionItem")
public class InspectionItemController {

    @Autowired
    InspectionItemService inspectionItemService;


    @PostMapping("/getInspectionItemByPage")
    public R export(@RequestBody InspectionItemDto materialDto)
    {
        return R.ok(inspectionItemService.getInspectionItemByPage(materialDto));
    }

    @PostMapping("/addInspectionItem")
    public R addTest(@RequestBody InspectionItemDto materialDto) throws ParseException {
        inspectionItemService.addInspectionItem(materialDto);
        return R.ok("添加成功");
    }

    @PostMapping("/delInspectionItem")
    public R delTest(@RequestBody InspectionItemDto materialDto){
        inspectionItemService.delInspectionItem(materialDto);
        return R.ok("删除成功");
    }

    @PostMapping("/updateInspectionItem")
    public R updateTest(@RequestBody InspectionItemDto materialDto){
        inspectionItemService.updateInspectionItem(materialDto);
        return R.ok("锁定成功");
    }

    /**
     * 上传质检接口 添加质检上传接口
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("/uploadInspectionItem")
    public R uploadInspectionItem(@RequestParam MultipartFile file) throws IOException {
        inspectionItemService.uploadInspectionItem(file);
        return R.ok("锁定成功");
    }


}
